package view;

import dao.BookList;
import service.BorrowBookService;
import service.ReturnBookService;

import java.util.Scanner;

/**
 * @Description TODO
 * @Author hhy
 * @Date 2020/9/17 10:35
 */
public class BookMenuView {
    BookList bookList = BookList.getInstance();
    public void view(){
        Scanner sc = new Scanner(System.in);
        System.out.println("*************主菜单************");
        System.out.println("1.查看书的列表");
        System.out.println("2.借书");
        System.out.println("3.还书");
        System.out.println("4.查看我有的书");
        System.out.println("5.返回上一级");
        int num = sc.nextInt();
        if (num==1){
            System.out.println("序号\t\t\t书名\t\t库存");
            BookList.getInstance().getBookList();  //查看书籍列表
            System.out.println("按任意键返回上一级");
            String next = sc.next();
            if (!next.equals("@（*&……*（&高总牛逼！！！！！")){
                view();
            }else {
                return;
            }


        }else if (num==2){
            new BorrowBookService().borrow();

        }else if (num==3){
            if (!bookList.myBorrowBookNum()){
                System.out.println("您没有借书，不需要还书哦~");
            }
            new ReturnBookService().returnBook();

        }else if (num==4){
            bookList.myBorrowBook();
            view();
        }else if (num==5){
            new MainView().view();
        }
    }
}
